package com.example.houtai.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.houtai.config.Logger;
import com.example.houtai.entity.SysLog;
import com.example.houtai.service.ISysLogService;
import com.org.dto.LogDto;
import com.org.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @author 龚梦
 * @since 2021-03-22
 */
@RestController
@RequestMapping("/sys/log")
public class SysLogController {

    @Autowired
    private ISysLogService logService;

    @Logger("日志查询")
    @RequestMapping("list")
    public ResultEntity list(@RequestBody LogDto logDto){

        Page<SysLog> page = new Page<>();

        page.setSize(logDto.getPageSize());

        page.setCurrent(logDto.getPageNum());

        if(logDto.getUsername()!=null){
            logDto.setOperation(logDto.getUsername());
        }

        Page<SysLog> logPage = logService.list(page,logDto.getUsername(),logDto.getOperation());

        return ResultEntity.ok("200","查询成功",logPage);
    }
}
